package com.xls.pet.listener;

import com.mybatisflex.annotation.SetListener;
import com.xls.pet.entity.Item;

public class ItemOnSetListener implements SetListener {
    @Override
    public Object onSet(Object entity, String property, Object value) {
        Item item = (Item) entity;
        if (property.equals("unit") && value != null) {
            switch ((int) value) {
                case 1:
                    item.setUnitString("年");
                    break;
                case 2:
                    item.setUnitString("月");
                    break;
                case 3:
                    item.setUnitString("日");
                    break;
                default:
                    item.setUnitString("未知");
            }
        }
        return value;
    }
}